package cemp.controller;


import cemp.service.StockCoreService;
import jakarta.servlet.http.HttpServletRequest;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Scanner;


@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/test")
public class TestController {

    @Autowired
    StockCoreService stockCoreService;

    @GetMapping("/list")
    public String list() {
        System.out.println("success-1");
        log.info("test core log list");
        return "success-1";
    }

    @GetMapping("/oom")
    public String oom() {
        stockCoreService.oom();
        return "oom";
    }

    @GetMapping("/exception")
    public String exception() {
        System.out.println("success-1");
        return "exception";
    }

    @GetMapping("/gateway/test")
    public String gatewayTest(@RequestHeader(value = "token",required = false)String tk,  HttpServletRequest request) {
        String token = request.getHeader("token");
        System.out.println(tk);
        System.out.println(token);
        System.out.println("success");
        return "success";
    }


}
